< previous page page_99 next page >

Page 99
On Error Resume Next
    Select Case Button.Key
        Case New
            ToDo: Add New button code.
            MsgBox Add New button code.
        Case Open
            ToDo: Add Open button code.
            MsgBox Add Open button code.
    End Select
Notice that each Case statement in the Select statement will execute based on the pressed button.
Tip
In an actual application, these
Case statements should call the same code routine as the related menu options. This allows you to program the action once, and then call it from both the menu and the toolbar. Doing this makes it easier to maintain your code because any changes or corrections have to be made only once.

At this point, your toolbar is ready for the remaining sections of your application code to be added.
Adding a Toolbar with the Wizard
You've made it this far and have seen the hoops you have to jump through to create a toolbar. To see how the Toolbar wizard works, start a new project and place the Windows Common Controls in your toolbox. Then, place the Toolbar control on your form. When you do this, the Toolbar wizard dialog box appears (see Figure 4.7).
The Toolbar Builder dialog box displays all the bitmaps available in the /GRAPHICS/TLBR_W95 directory in the left list box. All you need to do is locate the New and Open bitmaps in the list and move them to the list box on the right. If the bitmap you want isn't shown, click the fifth button from the top as shown in Figure 4.5. This will display the Image File Open dialog box for you to select another image. After you select the two bitmaps, the Toolbar Builder should look like the one in Figure 4.8.
When you're ready, click the Finish button. The Toolbar Builder will finish the add process; you'll see that ImageList and Toolbar controls have been added to your form. If you view the code for the form, you'll also see that the Button_click routine has been added for you, saving some coding time.

 
< previous page page_99 next page >

If you like this book, buy it!